package abg.core.mapper;

import abg.core.domain.db.ChatGroupUser;
import com.mybatisflex.core.query.QueryWrapper;

import java.util.List;

/**
 * 聊天群内成员
 */
public interface ChatGroupUserMapper extends ZBMapper<ChatGroupUser> {


    default ChatGroupUser getColumnByUserIdAndGroupId(String userId, String groupId, String... column) {
        QueryWrapper query = QueryWrapper.create().select(column).eq("user_id", userId).eq("group_id", groupId);
        return selectOneByQuery(query);
    }


    default List<ChatGroupUser> getColumnLimitById(String id, int limit, String... column) {
        QueryWrapper query = QueryWrapper.create().select(column).eq("id", id).limit(limit).orderBy("is_leader", false);
        return selectListByQuery(query);
    }

    default List<ChatGroupUser> getColumnListByKey(String key, String value, String... column) {
        QueryWrapper query = QueryWrapper.create().select(column).eq(key, value);
        return selectListByQuery(query);
    }


}
